"""

xpath 表达式
"""
from lxml import etree


def get_info(res):
    tree = etree.HTML(res.text)
    all_info = []

    company_name = ''.join(tree.xpath('//h1/text()'))

    item = {'com_id': str(res.url).replace('/', '').split('company')[1],
            'url_id': res.url,
            'company_name': company_name, }

    english_name = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"英文名称")]/following-sibling::td[1]/text()'))
    # 工商注册号
    registration_id = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"工商注册号")]/following-sibling::td[1]/text()'))
    # 同一信用代码
    unified_credit_code = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"统一社会信用代码")]/following-sibling::td[1]/text()'))
    # 法定代表人
    legal_represent = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"法定代表人")]/following-sibling::td[1]//a//text()'))
    # 组织机构代码
    organization_code = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"组织机构代码")]/following-sibling::td[1]/text()'))
    # 公司类型
    company_type = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"公司类型")]/following-sibling::td[1]/text()'))
    # 行业
    company_industry = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"行业")]/following-sibling::td[1]/text()'))
    # 经营状态
    company_status = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"经营状态")]/following-sibling::td[1]/text()'))
    # 注册资本
    registered_capital = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"注册资本")]/following-sibling::td[1]//text()'))
    # 注册时间
    registered_time = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"成立日期")]/following-sibling::td[1]//text()'))
    # 注册地址
    registered_address = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"注册地址")]/following-sibling::td[1]/text()'))
    # 营业期限
    business_term = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"营业期限")]/following-sibling::td[1]//text()'))
    # 经营范围
    business_range = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"经营范围")]/following-sibling::td[1]//text()'))
    # 登记机关
    registration_authority = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"登记机关")]/following-sibling::td[1]//text()'))
    # 核准日期--- 20年可能是时间元组-----------------
    approval_time = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"核准日期")]/following-sibling::td[1]//text()'))
    # 参保人数
    insured_persons_num = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"参保人数")]/following-sibling::td[1]//text()'))
    # 曾用名
    used_name = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"曾用名")]/following-sibling::td[1]//text()'))
    # 纳税人识别号
    taxpayer_identification_id = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"纳税人识别号")]/following-sibling::td[1]//text()'))
    # 纳税人资质
    taxpayer_qualification = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"纳税人资质")]/following-sibling::td[1]//text()'))
    # 实缴资本
    paid_capital = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"实缴资本")]/following-sibling::td[1]//text()'))
    # 人员规模
    personnel_scale = ''.join(
        tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"人员规模")]/following-sibling::td[1]//text()'))

    # 工商信息item-------------------------------------------------------------------------------------------------------------
    business_info_item = {'company_name': company_name, 'english_name': english_name,
                          'registration_id': registration_id, 'unified_credit_code': unified_credit_code,
                          'legal_represent': legal_represent, 'organization_code': organization_code,
                          'company_type': company_type, 'company_industry': company_industry,
                          'company_status': company_status, 'registered_capital': registered_capital,
                          'paid_capital': paid_capital,
                          'registered_time': registered_time, 'registered_address': registered_address,
                          'business_term': business_term, 'business_range': business_range,
                          'registration_authority': registration_authority, 'approval_time': approval_time,
                          'insured_persons_num': insured_persons_num, 'used_name': used_name,
                          'taxpayer_identification_id': taxpayer_identification_id,
                          'taxpayer_qualification': taxpayer_qualification, 'personnel_scale': personnel_scale, }
    # all_info.append(business_info_item)
    item['business_info'] = business_info_item

    # 联系方式item-------------------------------------------------------------------------------------------------------------
    company_phone = ''.join(
        tree.xpath('//*[@id="company_web_top"]//span[contains(text(),"电话")]/following-sibling::span[1]//text()'))
    more_phone = eval(''.join(tree.xpath('//*[@id="company_web_top"]//span/span[@class="hidden"]/text()')))
    company_email = ''.join(tree.xpath('//span[contains(@class,"email")]/text()'))
    company_link = ''.join(tree.xpath('//a[contains(@class,"company-link")]/text()'))
    company_address = ''.join(tree.xpath('//*[@id="company_base_info_address"]/text()')).strip()
    company_introduction = ''.join(tree.xpath('//span[contains(text(),"简介")]/../text()')).split()
    contact_info_item = {'company_phone': company_phone, 'more_phone': more_phone,
                         'company_email': company_email, 'company_link': company_link,
                         'company_address': company_address,
                         'company_introduction': company_introduction, }
    # all_info.append(contact_info_item)
    item['contact_info'] = contact_info_item

    # 分支机构-------------------------------------------------------------------------------------------------------------
    branchs = tree.xpath('//*[@id="_container_branch"]//table[contains(@class,"table")]/tbody/tr')
    _container_branch = []
    for tr in branchs:
        if tr.xpath('./td[1]/text()'):
            _container_branch.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                      'b_name': ''.join(tr.xpath('./td[2]//a/text()')),  # 企业名称
                                      'director': ''.join(tr.xpath('./td[3]//td[2]/a/text()')),  # 负责人
                                      'setup_time': ''.join(tr.xpath('./td[4]//text()')),  # 成立时间
                                      'status': ''.join(tr.xpath('./td[5]//text()')),  # 经营状态
                                      })
    # all_info.append({'__container_branch': __container_branch})
    item['_container_branch'] = _container_branch

    # 变更记录-------------------------------------------------------------------------------------------------------------
    change_records = tree.xpath('//*[@id="_container_changeinfo"]//table[contains(@class,"table")]/tbody/tr')
    _container_changeinfo = []
    for tr in change_records:
        _container_changeinfo.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                      'change_time': tr.xpath('./td[2]/text()')[0],  # 变更时间
                                      'change_project': ''.join(tr.xpath('./td[3]//text()')),  # 变更项目
                                      'change_before': ''.join(tr.xpath('./td[4]//text()')),  # 变更前
                                      'change_after': ''.join(tr.xpath('./td[5]//text()')),  # 变更后
                                      })
    # all_info.append({'__container_changeinfo': __container_changeinfo})
    item['_container_changeinfo'] = _container_changeinfo

    # 主要人员-------------------------------------------------------------------------------------------------------------
    staffs = tree.xpath('//*[@id="_container_staffCount"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_staffCount = []
    for tr in staffs:
        _container_staffCount.append({'no': ''.join(tr.xpath('./td[1]/text()')),  # 序号
                                      's_name': ''.join(tr.xpath('./td[2]//tr/td[2]/a/text()')),  # 姓名
                                      's_position': ''.join(tr.xpath('./td[3]/span/text()')),  # 职位
                                      's_holding': ''.join(tr.xpath('./td[4]//text()')),  # 持股比例
                                      's_beneficial_share': ''.join(tr.xpath('./td[5]//text()')),  # 最终受益股份
                                      })
    # all_info.append({'__container_staffCount': __container_staffCount})
    item['_container_staffCount'] = _container_staffCount

    # 二、================================================================================================================
    # 股东信息-------------------------------------------------------------------------------------------------------------
    holders = tree.xpath('//*[@id="_container_holderCount"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_holderCount = []
    for tr in holders:
        h_name = tr.xpath('./td[2]//tr/td[2]/a/text()')[0] if tr.xpath('./td[2]//tr/td[2]/a/text()') else \
            ''.join(tr.xpath('./td[2]//tr/td[2]//text()'))
        _container_holderCount.append({'no': ''.join(tr.xpath('./td[1]/text()')),  # 序号
                                       'h_name': h_name,  # 股东
                                       'h_proportion': ''.join(tr.xpath('./td[3]/div//text()')),  # 持股比例
                                       'h_benefit': ''.join(tr.xpath('./td[4]/span[1]/text()')),  # 最终受益股份
                                       'h_contribution': ''.join(tr.xpath('./td[5]//span//text()')),  # 认缴出资额
                                       'h_contribution_time': ''.join(tr.xpath('./td[6]//span//text()')),  # 认缴出资日期
                                       'h_relation_num': ''.join(tr.xpath('./td[2]//tr/td[3]//span/text()')),  # 关联企业数量
                                       })
    # all_info.append({'__container_holder': __container_holder})
    item['_container_holderCount'] = _container_holderCount

    # 股东及出资信息-------------------------------------------------------------------------------------------------------------
    holderList = tree.xpath('//*[@id="_container_holderList"]//table[contains(@class,"table")]/tbody/tr')
    _container_holderList = []
    for tr in holderList:
        _container_holderList.append({'no': ''.join(tr.xpath('./td[1]/text()')),  # 序号
                                      'hL_name': ''.join(tr.xpath('./td[2]//tr/td[2]//text()')),  # 股东
                                      'hL_detail': ''.join(tr.xpath('./td[8]/script//text()')),  # 持股比例
                                      })
    # all_info.append({'__container_holder': __container_holder})
    item['_container_holderList'] = _container_holderList

    # 三、================================================================================================================
    # 对外投资信息-------------------------------------------------------------------------------------------------------------
    out_investments = tree.xpath('//*[@id="_container_invest"]//table[contains(@class,"table")]/tbody/tr')
    _container_invest = []
    for tr in out_investments:
        if tr.xpath('./td[1]/text()'):
            _container_invest.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                      'o_name': tr.xpath('./td[2]//a/text()')[0],  # 被投资企业名称
                                      'o_person': tr.xpath('./td[3]//a/text()')[0],  # 法定代表人
                                      'o_set_time': tr.xpath('./td[4]//text()')[0],  # 成立时间
                                      'o_money': tr.xpath('./td[5]//text()')[0],  # 投资数额
                                      'o_ratio': tr.xpath('./td[6]//text()')[0],  # 投资比例
                                      'o_status': tr.xpath('./td[7]//text()')[0],  # 经营状态
                                      'o_rel_products': tr.xpath('./td[8]//text()')[0],  # 关联产品
                                      'o_rel_institutions': tr.xpath('./td[9]//text()')[0],  # 关联机构
                                      })
    # all_info.append({'__container_invest': __container_invest})
    item['_container_invest'] = _container_invest

    # 四、法定代表人相关信息================================================================================================================
    # 担任法定代表人的企业信息-------------------------------------------------------------------------------------------------------------
    law_represents = tree.xpath('//*[@id="_container_baseInfo"]//td[contains(text(),"法定代表人")]/following-sibling::td[1]//div[contains(@class,"bottom")]')
    _container_baseInfo = []
    for tr in law_represents:
        _container_baseInfo.append({'represent': legal_represent,  # 法定代表人
                                    'lr_info': ''.join(tr.xpath('.//text()')).strip(),  # 区域上包含的公司
                                    })
    # all_info.append({'__container_baseInfo': __container_baseInfo})
    item['_container_baseInfo'] = _container_baseInfo

    # 五、企业发展================================================================================================================
    # 融资历程-------------------------------------------------------------------------------------------------------------
    financing_historys = tree.xpath('//*[@id="_container_rongzi"]//table[contains(@class,"table")]/tbody/tr')
    _container_rongzi = []
    for tr in financing_historys:
        _container_rongzi.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'r_time': tr.xpath('./td[2]/text()')[0],  # 披露日期
                                  'r_money': tr.xpath('./td[3]/text()')[0],  # 交易金额
                                  'r_round': tr.xpath('./td[4]//text()')[0],  # 融资轮次
                                  'r_value': tr.xpath('./td[5]//text()')[0],  # 估值
                                  'r_ratio': tr.xpath('./td[6]//text()')[0],  # 比例
                                  'r_investor': ' '.join(tr.xpath('./td[7]//text()')),  # 投资方
                                  'r_news': ''.join(tr.xpath('./td[8]//text()')),  # 新闻来源
                                  })
    # all_info.append({'__container_rongzi': __container_rongzi})
    item['_container_rongzi'] = _container_rongzi

    # 投资事件------------------------------------------------------------------------------------------------------------
    investment_events = tree.xpath('//*[@id="_container_touzi"]//table[contains(@class,"table")]/tbody/tr')
    _container_touzi = []
    for tr in investment_events:
        _container_touzi.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                 't_time': tr.xpath('./td[2]/text()')[0],  # 投资日期
                                 't_round': tr.xpath('./td[3]/text()')[0],  # 参与轮次
                                 't_investor': tr.xpath('./td[4]//text()')[0],  # 投资方
                                 't_money': tr.xpath('./td[5]//text()')[0],  # 投资金额
                                 't_product_name': tr.xpath('./td[6]//a/text()')[0],  # 产品名称
                                 't_label': tr.xpath('./td[7]//a/text()')[0],  # 产品标签
                                 't_add': tr.xpath('./td[8]//text()')[0],  # 所属地
                                 't_info': tr.xpath('./td[9]//text()')[0],  # 简介
                                 })
    # all_info.append({'__container_touzi': __container_touzi})
    item['_container_touzi'] = _container_touzi

    # 核心团队------------------------------------------------------------------------------------------------------------
    main_teams = tree.xpath('//*[@id="_container_teamMember"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_teamMember = []
    for tr in main_teams:
        _container_teamMember.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                      'tm_person': tr.xpath('./td[2]//tr/td[2]//text()')[0],  # 姓名
                                      'tm_position': tr.xpath('./td[3]/text()')[0],  # 职位
                                      'tm_info': tr.xpath('./td[4]//text()')[0],  # 简介
                                      })
    # all_info.append({'__container_teamMember': __container_teamMember})
    item['_container_teamMember'] = _container_teamMember

    # 企业业务------------------------------------------------------------------------------------------------------------
    company_business = tree.xpath('//*[@id="_container_firmProduct"]//table[contains(@class,"table")]/tbody/tr')
    _container_firmProduct = []
    for tr in company_business:
        _container_firmProduct.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                       'fp_product_name': tr.xpath('./td[2]//tr/td[2]//text()')[0],  # 产品名称
                                       'fp_time': tr.xpath('./td[3]/text()')[0],  # 成立日期
                                       'fp_now_round': tr.xpath('./td[4]//text()')[0],  # 当前融资轮次
                                       'fp_product_label': tr.xpath('./td[5]//text()')[0],  # 产品标签
                                       'fp_add': tr.xpath('./td[6]//text()')[0],  # 所属地
                                       'fp_product_info': tr.xpath('./td[7]//div/text()')[0],  # 产品介绍
                                       })
    # all_info.append({'__container_firmProduct': __container_firmProduct})
    item['_container_firmProduct'] = _container_firmProduct

    # 竞品信息------------------------------------------------------------------------------------------------------------
    jingpin = tree.xpath('//*[@id="_container_jingpin"]//table[contains(@class,"table")]/tbody/tr')
    _container_jingpin = []
    for tr in jingpin:
        _container_jingpin.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                   'j_product_name': tr.xpath('./td[2]//tr/td[2]//text()')[0],  # 产品名称
                                   'j_now_round': tr.xpath('./td[3]/text()')[0],  # 当前融资轮次
                                   'j_valuation': tr.xpath('./td[4]//text()')[0],  # 估值
                                   'j_set_time': tr.xpath('./td[5]//text()')[0],  # 成立日期
                                   'j_label': ''.join(tr.xpath('./td[6]//text()')),  # 产品标签
                                   'j_add': ''.join(tr.xpath('./td[7]//text()')),  # 所属地
                                   'j_info': ''.join(tr.xpath('./td[8]//text()')),  # 简介
                                   'j_owned_company': ''.join(tr.xpath('./td[9]//text()')),  # 所属公司
                                   })
    # all_info.append({'__container_jingpin': __container_jingpin})
    item['_container_jingpin'] = _container_jingpin

    # 招聘信息------------------------------------------------------------------------------------------------------------
    baipin = tree.xpath('//*[@id="_container_baipin"]//table[contains(@class,"table")]/tbody/tr')
    _container_baipin = []
    for tr in baipin:
        _container_baipin.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'bp_release_date': tr.xpath('./td[2]//text()')[0],  # 发布日期
                                  'bp_job': tr.xpath('./td[3]/text()')[0],  # 招聘职位
                                  'bp_salary': tr.xpath('./td[4]//text()')[0],  # 月薪
                                  'bp_education': tr.xpath('./td[5]//text()')[0],  # 学历
                                  'bp_experience': ''.join(tr.xpath('./td[6]//text()')),  # 工作经验
                                  'bp_add': ''.join(tr.xpath('./td[7]//text()')),  # 地区
                                  'bp_detail_href': ''.join(tr.xpath('./td[8]/a/@href')),  # 详情连接
                                  })
    # all_info.append({'__container_baipin': __container_baipin})
    item['_container_baipin'] = _container_baipin

    # 新闻舆情------------------------------------------------------------------------------------------------------------
    findNewsCount = tree.xpath('//*[@id="_container_findNewsCount"]/div[contains(@class,"news")]/div')
    _container_findNewsCount = []
    for tr in findNewsCount:
        _container_findNewsCount.append({'new_title': tr.xpath('./div/div/a/text()')[0],  # 新闻标题
                                         'bp_content': ''.join(tr.xpath('.//div[contains(@class,"abstracts")]/text()')),
                                         # 新闻内容
                                         'bp_source': ''.join(
                                             tr.xpath('.//div[contains(@class,"infos")]/span[1]/text()')),  # 来源
                                         'bp_release——time': ''.join(
                                             tr.xpath('.//div[contains(@class,"infos")]/span[2]/text()')),  # 发布时间
                                         'bp_related': ''.join(
                                             tr.xpath('.//div[contains(@class,"infos")]/span[3]//text()')),  # 相关
                                         'bp_detail_href': ''.join(tr.xpath('./div/div/a/@href')),  # 详情连接
                                         })
    # all_info.append({'__container_findNewsCount': __container_findNewsCount})
    item['_container_findNewsCount'] = _container_findNewsCount

    # 六、风险信息================================================================================================================
    # # 司法解析-------------------------------------------------------------------------------------------------------------
    judicialCase = tree.xpath('//*[@id="_container_judicialCase"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_judicialCase = []
    for tr in judicialCase:
        _container_judicialCase.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                        'jc_name': tr.xpath('./td[2]//text()')[0],  # 案件名称
                                        'jc_case_num': tr.xpath('./td[3]//text()')[0],  # 相关案号
                                        'jc_case_cause': tr.xpath('./td[4]//text()')[0],  # 案由
                                        'jc_case_type': tr.xpath('./td[5]//text()')[0],  # 案件类型
                                        'jc_case_status': tr.xpath('./td[6]//text()')[0],  # 案件身份
                                        'jc_trial_procedure': tr.xpath('./td[7]//text()')[0],  # 当前审理程序
                                        'jc_trial_procedure_date': tr.xpath('./td[8]//text()')[0],  # 当前审理程序日期
                                        'jc_detail_href': tr.xpath('./td[9]/a/@href')[0],  # 详情url
                                        })
    # all_info.append({'__container_judicialCase': __container_judicialCase})
    item['_container_judicialCase'] = _container_judicialCase

    # 1、被执行人信息-------------------------------------------------------------------------------------------------------------
    risk_executor_infos = tree.xpath('//*[@id="_container_zhixing"]//table[contains(@class,"table")]/tbody/tr')
    _container_zhixing = []
    for tr in risk_executor_infos:
        _container_zhixing.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                   'z_set_time': tr.xpath('./td[2]//text()')[0],  # 立案日期
                                   'z_case_num': tr.xpath('./td[3]/text()')[0],  # 案号
                                   'z_execution_matter': tr.xpath('./td[4]//text()')[0],  # 执行标的
                                   'z_court': tr.xpath('./td[5]//text()')[0],  # 执行法院
                                   })
    # all_info.append({'__container_zhixing': __container_zhixing})
    item['_container_zhixing'] = _container_zhixing

    # 2、法律诉讼-------------------------------------------------------------------------------------------------------------
    law_litigations = tree.xpath('//*[@id="_container_lawsuit"]//table[contains(@class,"table")]/tbody/tr')
    _container_lawsuit = []
    for tr in law_litigations:
        _container_lawsuit.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                   'l_set_time': tr.xpath('./td[2]//text()')[0],  # 发布日期
                                   'l_case_name': tr.xpath('./td[3]/text()')[0],  # 案件名称
                                   'l_case_num': tr.xpath('./td[4]//text()')[0],  # 案号
                                   'l_case_reason': tr.xpath('./td[5]//text()')[0],  # 案由
                                   'l_case_status': ' '.join(tr.xpath('./td[6]//text()')),  # 案件身份
                                   'l_referee_result': ''.join(tr.xpath('./td[7]//text()')),  # 裁判结果
                                   'l_trial_court': ''.join(tr.xpath('./td[8]//text()')),  # 审理法院
                                   'l_release_date': ''.join(tr.xpath('./td[9]//text()')),  # 发布日期
                                   'l_detail_link': ''.join(tr.xpath('./td[10]//a/@href')),  # 详情连接
                                   })
    # all_info.append({'__container_lawsuit': __container_lawsuit})
    item['_container_lawsuit'] = _container_lawsuit

    # # 立案信息-------------------------------------------------------------------------------------------------------------
    courtRegister = tree.xpath('//*[@id="_container_courtRegister"]//table[contains(@class,"table")]/tbody/tr')
    _container_courtRegister = []
    for tr in courtRegister:
        _container_courtRegister.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                         'cr_set_time': tr.xpath('./td[2]//text()')[0],  # 立案日期
                                         'cr_case_num': tr.xpath('./td[3]/text()')[0],  # 案号
                                         'cr_case_status': ''.join(tr.xpath('./td[4]//text()')),  # 案件身份
                                         'cr_court': tr.xpath('./td[5]//text()')[0],  # 法院
                                         'cr_detail_info': ''.join(tr.xpath('./td[6]/script/text()')),  # 详情信息
                                         })
    # all_info.append({'__container_courtRegister': __container_courtRegister})
    item['_container_courtRegister'] = _container_courtRegister

    # 3、法院公告-------------------------------------------------------------------------------------------------------------
    court_notices = tree.xpath('//*[@id="_container_court"]//table[contains(@class,"table")]/tbody/tr')
    _container_court = []
    for tr in court_notices:
        _container_court.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                 'c_set_time': tr.xpath('./td[2]//text()')[0],  # 刊登日期
                                 'c_case_id': tr.xpath('./td[3]//text()')[0],  # 案号
                                 'c_case_cause': tr.xpath('./td[4]//text()')[0],  # 案由
                                 'c_case_status': ''.join(tr.xpath('./td[5]//text()')),  # 案件身份
                                 'c_type': ' '.join(tr.xpath('./td[6]//text()')),  # 公告类型
                                 'c_court': tr.xpath('./td[7]//text()')[0],  # 法院
                                 'detail': tr.xpath('./td[8]/a/@href'),  # 详情网址
                                 })
    # all_info.append({'__container_court': __container_court})
    item['_container_court'] = _container_court

    # 送达公告-------------------------------------------------------------------------------------------------------------
    sendAnnouncements = tree.xpath('//*[@id="_container_sendAnnouncements"]//table[contains(@class,"table")]/tbody/tr')
    _container_sendAnnouncements = []
    for tr in sendAnnouncements:
        _container_sendAnnouncements.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                             'sa_issue_date': tr.xpath('./td[2]//text()')[0],  # 发步日期
                                             'sa_announcement_name': tr.xpath('./td[3]//div/text()')[0],  # 公告名称
                                             'sa_case_id': tr.xpath('./td[4]//text()')[0],  # 案号
                                             'sa_case_cause': ''.join(tr.xpath('./td[5]//text()')),  # 案由
                                             'sa_case_status': ' '.join(tr.xpath('./td[6]//text()')),  # 案件身份
                                             'sa_detail': ''.join(tr.xpath('./td[7]/script/text()')),  # 详情
                                             })
    # all_info.append({'__container_court': __container_court})
    item['_container_sendAnnouncements'] = _container_sendAnnouncements

    # 4.行政处罚-------------------------------------------------------------------------------------------------------------
    punishs = tree.xpath('//*[@id="_container_punishmentV2"]//table[contains(@class,"table")]/tbody/tr')
    _container_punishmentV2 = []
    for tr in punishs:
        _container_punishmentV2.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                        'p2_set_time': tr.xpath('./td[2]//text()')[0],  # 处罚日期
                                        'p2_doc_id': tr.xpath('./td[3]//text()')[0],  # 决定书文号
                                        'p2_violations_type': ''.join(tr.xpath('./td[4]//div/text()')).replace('\xa0',
                                                                                                               ''),
                                        # 处罚事由/违法行为类型
                                        'p2_result': ' '.join(tr.xpath('./td[5]//div/text()')).replace('\xa0', ''),
                                        # 处罚结果/内容
                                        'p2_punishment_unit': ' '.join(tr.xpath('./td[6]//text()')),  # 处罚单位
                                        'p2_data_sources': ' '.join(tr.xpath('./td[7]//text()')),  # 数据来源
                                        })
    # all_info.append({'__container_punish': __container_punish})
    item['_container_punishmentV2'] = _container_punishmentV2

    # 5.股权出质-------------------------------------------------------------------------------------------------------------
    equitys = tree.xpath('//*[@id="_container_equity"]//table[contains(@class,"table")]/tbody/tr')
    _container_equity = []
    for tr in equitys:
        _container_equity.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'e_set_time': tr.xpath('./td[2]//text()')[0],  # 股权出质设立登记日期
                                  'e_login_id': tr.xpath('./td[3]//text()')[0],  # 登记编号
                                  'e_pledgor': tr.xpath('./td[4]//text()')[0],  # 出质人
                                  'e_pledged_equity': ' '.join(tr.xpath('./td[5]//text()')),  # 出质股权标的企业
                                  'e_pledgee': ' '.join(tr.xpath('./td[6]//text()')),  # 质权人
                                  'e_pledged_num': ' '.join(tr.xpath('./td[7]//text()')),  # 出质股权数额
                                  'e_status': ' '.join(tr.xpath('./td[8]//text()')),  # 状态
                                  })
    # all_info.append({'__container_equity': __container_equity})
    item['_container_equity'] = _container_equity

    # 6.动产抵押-------------------------------------------------------------------------------------------------------------
    mortgage = tree.xpath('//*[@id="_container_mortgage"]//table[contains(@class,"table")]/tbody/tr')
    _container_mortgage = []
    for tr in mortgage:
        _container_mortgage.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                    'm_login_time': tr.xpath('./td[2]//text()')[0],  # 登记日期
                                    'm_login_id': tr.xpath('./td[3]//text()')[0],  # 登记编号
                                    'm_type': tr.xpath('./td[4]//text()')[0],  # 被担保债权类型
                                    'm_money': ' '.join(tr.xpath('./td[5]//text()')),  # 被担保债权数额
                                    'm_login_office': ' '.join(tr.xpath('./td[5]//text()')),  # 登记机关
                                    })
    # all_info.append({'__container_mortgage': __container_mortgage})
    item['_container_mortgage'] = _container_mortgage

    # 7.经营异常-------------------------------------------------------------------------------------------------------------
    abnormalRemove = tree.xpath('//*[@id="_container_abnormalRemove"]//table[contains(@class,"table")]/tbody/tr')
    _container_abnormalRemove = []
    for tr in abnormalRemove:
        _container_abnormalRemove.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'ar_set_time': tr.xpath('./td[2]//text()')[0],  # 列入日期
                                          'ar_reason': tr.xpath('./td[3]//text()')[0],  # 列入经营异常名录原因
                                          'ar_decision_office': tr.xpath('./td[4]//text()')[0],  # 作出决定机关
                                          'ar_remove_time': ' '.join(tr.xpath('./td[5]//text()')),  # 移出日期
                                          'ar_remove_reason': ' '.join(tr.xpath('./td[6]//text()')),  # 移出经营异常名录原因
                                          })
    # all_info.append({'__container_abnormalRemove': __container_abnormalRemove})
    item['_container_abnormalRemove'] = _container_abnormalRemove

    # 8、开庭公告-------------------------------------------------------------------------------------------------------------
    announcementcourt = tree.xpath('//*[@id="_container_announcementcourt"]//table[contains(@class,"table")]/tbody/tr')
    _container_announcementcourt = []
    for tr in announcementcourt:
        _container_announcementcourt.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                             'ac_time': tr.xpath('./td[2]//text()')[0],  # 开庭日期
                                             'ac_case_id': tr.xpath('./td[3]//text()')[0],  # 案号
                                             'ac_case_reason': tr.xpath('./td[4]//text()')[0],  # 案由
                                             'ac_status': ' '.join(tr.xpath('./td[5]//text()')),  # 案件身份
                                             'ac_trial_court': ' '.join(tr.xpath('./td[6]//text()')),  # 审理法院
                                             'ac_detail_info': ' '.join(tr.xpath('./td[7]/script/text()')),  # 详情信息
                                             })
    # all_info.append({'__container_announcementcourt': __container_announcementcourt})
    item['_container_announcementcourt'] = _container_announcementcourt

    # 9、司法拍卖-------------------------------------------------------------------------------------------------------------
    judicialSale = tree.xpath('//*[@id="_container_judicialSale"]//table[contains(@class,"table")]/tbody/tr')
    _container_judicialSale = []
    for tr in judicialSale:
        _container_judicialSale.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                        'js_time': tr.xpath('./td[2]//text()')[0],  # 公告日期
                                        'js_notice': tr.xpath('./td[3]//text()')[0],  # 拍卖公告
                                        'js_target': tr.xpath('./td[4]//text()')[0],  # 拍卖标的
                                        'js_court': ' '.join(tr.xpath('./td[5]//text()')),  # 执行法院
                                        })
    # all_info.append({'__container_judicialSale': __container_judicialSale})
    item['_container_judicialSale'] = _container_judicialSale

    # 七、知识产权信息================================================================================================================
    # 1、商标信息-------------------------------------------------------------------------------------------------------------
    tmInfo = tree.xpath('//*[@id="_container_tmInfo"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_tmInfo = []
    for tr in tmInfo:
        _container_tmInfo.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'ti_time': tr.xpath('./td[2]//text()')[0],  # 申请日期
                                  'ti_logo': tr.xpath('./td[3]//img/@data-src')[0],  # 商标
                                  'ti_logo_name': tr.xpath('./td[4]//text()')[0],  # 商标名称
                                  'ti_reg_id': ' '.join(tr.xpath('./td[5]//text()')),  # 注册号
                                  'ti_inter_group': ' '.join(tr.xpath('./td[6]//text()')),  # 国际分类
                                  'ti_logo_status': ' '.join(tr.xpath('./td[7]//text()')),  # 商标状态
                                  })
    # all_info.append({'__container_tmInfo': __container_tmInfo})
    item['_container_tmInfo'] = _container_tmInfo

    # 2、专利信息-------------------------------------------------------------------------------------------------------------
    patent = tree.xpath('//*[@id="_container_patent"]//table[contains(@class,"table")]/tbody/tr')
    _container_patent = []
    for tr in patent:
        _container_patent.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'p_application_day': tr.xpath('./td[2]//text()')[0],  # 申请日
                                  'p_name': tr.xpath('./td[3]//text()')[0],  # 专利名称
                                  'p_type': ''.join(tr.xpath('./td[4]//text()')),  # 专利类型
                                  'p_law_status': tr.xpath('./td[5]//text()')[0],  # 法律状态
                                  'p_application_num': ' '.join(tr.xpath('./td[6]//text()')),  # 申请号
                                  'p_public_num': ' '.join(tr.xpath('./td[7]//text()')),  # 公开（公布）号
                                  'p_public_day': ' '.join(tr.xpath('./td[8]//text()')),  # 公开（公告）日
                                  'p_href': ' '.join(tr.xpath('./td[9]//a/@href')),  # 详情连接
                                  })
    # all_info.append({'__container_patent': __container_patent})
    item['_container_patent'] = _container_patent

    # 3、软件著作权-------------------------------------------------------------------------------------------------------------
    copyright = tree.xpath('//*[@id="_container_copyright"]//table[contains(@class,"table")]/tbody/tr')
    _container_copyright = []
    for tr in copyright:
        _container_copyright.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                     'cr_time': ''.join(tr.xpath('./td[2]//text()')),  # 登记批准日期
                                     'cr_name': ''.join(tr.xpath('./td[3]//text()')),  # 软件全称
                                     'cr_easy_name': ''.join(tr.xpath('./td[4]//text()')),  # 软件简称
                                     'cr_license_num': ' '.join(tr.xpath('./td[5]//text()')),  # 登记号
                                     'cr_type_id': ' '.join(tr.xpath('./td[6]//text()')),  # 分类号
                                     'cr_ver_id': ' '.join(tr.xpath('./td[7]//text()')),  # 版本号
                                     'cr_first_published_date': ' '.join(tr.xpath('./td[8]//text()')),  # 首次发表日期
                                     'cr_detail': ' '.join(tr.xpath('./td[9]//text()')),  # 详情
                                     })
    # all_info.append({'__container_copyright': __container_copyright})
    item['_container_copyright'] = _container_copyright

    # 4、作品著作权-------------------------------------------------------------------------------------------------------------
    copyrightWorks = tree.xpath('//*[@id="_container_copyrightWorks"]//table[contains(@class,"table")]/tbody/tr')
    _container_copyrightWorks = []
    for tr in copyrightWorks:
        _container_copyrightWorks.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'crw_name': tr.xpath('./td[2]//text()')[0],  # 作品名称
                                          'crw_id': tr.xpath('./td[3]//text()')[0],  # 登记号
                                          'crw_type': tr.xpath('./td[4]//text()')[0],  # 作品类别
                                          'crw_finish_time': ''.join(tr.xpath('./td[5]//text()')),  # 创作完成日期
                                          'crw_login_time': ''.join(tr.xpath('./td[6]//text()')),  # 登记日期
                                          'crw_first_time': ''.join(tr.xpath('./td[7]//text()')),  # 首次发表日期
                                          })
    # all_info.append({'__container_copyrightWorks': __container_copyrightWorks})
    item['_container_copyrightWorks'] = _container_copyrightWorks

    # 5、网站备案-------------------------------------------------------------------------------------------------------------
    icp = tree.xpath('//*[@id="_container_icp"]//table[contains(@class,"table")]/tbody/tr')
    _container_icp = []
    for tr in icp:
        _container_icp.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                               'icp_time': tr.xpath('./td[2]//text()')[0],  # 审核日期
                               'icp_url_name': tr.xpath('./td[3]//text()')[0],  # 网站名称
                               'icp_url_index': tr.xpath('./td[4]//a/text()')[0],  # 网站首页
                               'icp_url': ''.join(tr.xpath('./td[5]//text()')),  # 域名
                               'icp_case_id': ''.join(tr.xpath('./td[6]//text()')),  # 网站备案/许可证号
                               'icp_public_security_record': ''.join(tr.xpath('./td[7]//text()')),  # 公安备案
                               })
    # all_info.append({'__container_icp': __container_icp})
    item['_container_icp'] = _container_icp

    # 八、经营信息================================================================================================================
    # 一般纳税人-------------------------------------------------------------------------------------------------------------
    commonTaxpayer = tree.xpath('//*[@id="_container_commonTaxpayer"]//table[contains(@class,"table")]/tbody/tr')
    _container_commonTaxpayer = []
    for tr in commonTaxpayer:
        _container_commonTaxpayer.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'ct_taxpayer_name': tr.xpath('./td[2]//a/text()')[0],  # 纳税人名称
                                          'ct_taxpayer_id': tr.xpath('./td[3]//text()')[0],  # 纳税人识别号
                                          'ct_taxpayer_qualification_type': tr.xpath('./td[4]//text()')[0],  # 纳税人资格类型
                                          'ct_tax_authorities': tr.xpath('./td[5]//text()')[0],  # 主管税务机关
                                          'ct_Eexpiration_date': tr.xpath('./td[6]//text()')[0],  # 有效期止
                                          })
    # all_info.append({'__container_commonTaxpayer': __container_commonTaxpayer})
    item['_container_commonTaxpayer'] = _container_commonTaxpayer

    # 8.1 招投标-------------------------------------------------------------------------------------------------------------
    bid = tree.xpath('//*[@id="_container_bid"]//table[contains(@class,"table")]/tbody/tr')
    _container_bid = []
    for tr in bid:
        _container_bid.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                               'bid_time': tr.xpath('./td[2]//text()')[0],  # 发布日期
                               'bid_title': tr.xpath('./td[3]//text()')[0],  # 标题
                               'bid_purchaser': tr.xpath('./td[4]//text()')[0],  # 采购人
                               })
    # all_info.append({'__container_bid': __container_bid})
    item['_container_bid'] = _container_bid

    # 8.2 债券信息-------------------------------------------------------------------------------------------------------------
    bond = tree.xpath('//*[@id="_container_bond"]//table[contains(@class,"table")]/tbody/tr')
    _container_bond = []
    for tr in bond:
        _container_bond.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                'bond_time': tr.xpath('./td[2]//text()')[0],  # 发行日期
                                'bond_name': tr.xpath('./td[3]//text()')[0],  # 债券名称
                                'bond_code': tr.xpath('./td[4]//text()')[0],  # 债券代码
                                'bond_type': tr.xpath('./td[5]//text()')[0],  # 债券类型
                                'bond_newlevel': tr.xpath('./td[6]//text()')[0],  # 最新评级
                                })
    # all_info.append({'__container_bond': __container_bond})
    item['_container_bond'] = _container_bond

    # 8.3 招聘信息-------------------------------------------------------------------------------------------------------------
    baipin = tree.xpath('//*[@id="_container_baipin"]//table[contains(@class,"table")]/tbody/tr')
    _container_baipin = []
    for tr in baipin:
        _container_baipin.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'bp_time': tr.xpath('./td[2]//text()')[0],  # 发布日期
                                  'bp_position': tr.xpath('./td[3]//text()')[0],  # 招聘职位
                                  'bp_salary': tr.xpath('./td[4]//text()')[0],  # 月薪
                                  'bp_education': tr.xpath('./td[5]//text()')[0],  # 学历
                                  'bp_exp': tr.xpath('./td[6]//text()')[0],  # 工作经验
                                  'bp_add': tr.xpath('./td[7]//text()')[0],  # 地区
                                  })
    # all_info.append({'__container_baipin': __container_baipin})
    item['_container_baipin'] = _container_baipin

    # 8.4 税务评级-------------------------------------------------------------------------------------------------------------
    taxcredit = tree.xpath('//*[@id="_container_taxcredit"]//table[contains(@class,"table")]/tbody/tr')
    _container_taxcredit = []
    for tr in taxcredit:
        _container_taxcredit.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                     'tc_year': tr.xpath('./td[2]//text()')[0],  # 评价年度
                                     'tc_credit_level': tr.xpath('./td[3]//text()')[0],  # 纳税人信用级别
                                     'tc_type': tr.xpath('./td[4]//text()')[0],  # 类型
                                     'tc_id': tr.xpath('./td[5]//text()')[0],  # 纳税人识别号
                                     'tc_unit': tr.xpath('./td[6]//text()')[0],  # 评价单位
                                     })
    # all_info.append({'__container_taxcredit': __container_taxcredit})
    item['_container_taxcredit'] = _container_taxcredit

    # 8.5 购地信息-------------------------------------------------------------------------------------------------------------
    purchaselandV2 = tree.xpath('//*[@id="_container_purchaselandV2"]//table[contains(@class,"table")]/tbody/tr')
    _container_purchaselandV2 = []
    for tr in purchaselandV2:
        _container_purchaselandV2.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'pl_seat': tr.xpath('./td[2]//text()')[0],  # 项目位置
                                          'pl_use': tr.xpath('./td[3]//text()')[0],  # 土地用途
                                          'pl_area': tr.xpath('./td[4]//text()')[0],  # 面积（公顷）
                                          'pl_region': tr.xpath('./td[5]//text()')[0],  # 行政区
                                          'pl_mode': tr.xpath('./td[6]//text()')[0],  # 供地方式
                                          'pl_contract': tr.xpath('./td[7]//text()')[0],  # 合同签订日期
                                          })
    # all_info.append({'__container_purchaselandV2': __container_purchaselandV2})
    item['_container_purchaselandV2'] = _container_purchaselandV2

    # 8.6 资质证书-------------------------------------------------------------------------------------------------------------
    certificate = tree.xpath('//*[@id="_container_certificate"]//table[contains(@class,"table")]/tbody/tr')
    _container_certificate = []
    for tr in certificate:
        _container_certificate.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                       'cf_time': tr.xpath('./td[2]//text()')[0],  # 发证日期
                                       'cf_type': tr.xpath('./td[3]//text()')[0],  # 证书类型
                                       'cf_product_name_unit': tr.xpath('./td[4]//text()')[0],  # 产品名称及单元(主)
                                       'cf_id': tr.xpath('./td[5]//text()')[0],  # 证书编号
                                       'cf_stop_time': tr.xpath('./td[6]//text()')[0],  # 截止日期
                                       })
    # all_info.append({'__container_certificate': __container_certificate})
    item['_container_certificate'] = _container_certificate

    # 8.7 抽查检查-------------------------------------------------------------------------------------------------------------
    # 8.7.1市场监管---------------
    check = tree.xpath('//*[@id="_container_check"]//table[contains(@class,"table")]/tbody/tr')
    _container_check = []
    for tr in check:
        _container_check.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                 'che_time': tr.xpath('./td[2]//text()')[0],  # 日期
                                 'che_type': tr.xpath('./td[3]//text()')[0],  # 类型
                                 'che_finish': tr.xpath('./td[4]//text()')[0],  # 结果
                                 'che_office': tr.xpath('./td[5]//text()')[0],  # 检查实施机关
                                 })
    # all_info.append({'__container_check': __container_check})
    item['_container_check'] = _container_check

    # 8.7.2产品质量监督----------------------------------------------------------------------
    productQualitySupervision = tree.xpath(
        '//*[@id="_container_productQualitySupervision"]//table[contains(@class,"table")]/tbody/tr')
    _container_productQualitySupervision = []
    for tr in productQualitySupervision:
        _container_productQualitySupervision.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                                     'pqs_release_date': tr.xpath('./td[2]//text()')[0],  # 结果发布日期
                                                     'pqs_name': tr.xpath('./td[3]//text()')[0],  # 产品名称
                                                     'pqs_specification_model': tr.xpath('./td[4]//text()')[0],  # 规格型号
                                                     'pqs_production_date_batch': tr.xpath('./td[5]//text()')[0],
                                                     # 生产日期/批号
                                                     'pqs_results': tr.xpath('./td[6]//text()')[0],  # 抽查结果
                                                     'pqs_unqualified': tr.xpath('./td[7]//text()')[0],  # 主要不合格项目
                                                     'pqs_inspection_organization': tr.xpath('./td[8]//text()')[0],
                                                     # 承检机构
                                                     })
    # all_info.append({'__container_check': __container_check})
    item['_container_productQualitySupervision'] = _container_productQualitySupervision

    # 8.8 产品信息-------------------------------------------------------------------------------------------------------------
    product = tree.xpath('//*[@id="_container_product"]//table[contains(@class,"table")]/tbody/tr')
    _container_product = []
    for tr in product:
        _container_product.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                   'pro_name': tr.xpath('./td[2]//text()')[0],  # 产品名称
                                   'pro_easy_name': tr.xpath('./td[3]//text()')[0],  # 产品简称
                                   'pro_group': tr.xpath('./td[4]//text()')[0],  # 产品分类
                                   'pro_field': tr.xpath('./td[5]//text()')[0],  # 领域领域
                                   'pro_detail': tr.xpath('./td[6]/a/@href')[0],  # 操作
                                   })
    # all_info.append({'__container_product': __container_product})
    item['_container_product'] = _container_product

    # 8.9 进出口信息-------------------------------------------------------------------------------------------------------------
    # 行政许可
    licensing = tree.xpath('//*[@id="_container_licensing"]//table[contains(@class,"table")]/tbody/tr')
    _container_licensing = []
    for tr in licensing:
        _container_licensing.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                     'ls_star_time': tr.xpath('./td[2]//text()')[0],  # 决定日期/有效期自
                                     'ls_end_time': tr.xpath('./td[3]//text()')[0],  # 截止日期/有效期至
                                     'ls_file_id': tr.xpath('./td[4]/text()')[0],  # 许可文件编号/文书号
                                     'ls_file_name': tr.xpath('./td[5]//text()')[0],  # 许可文件名称
                                     'ls_office': tr.xpath('./td[6]//text()')[0],  # 决定/许可机关
                                     'ls_content': tr.xpath('./td[7]//div/text()')[0],  # 许可内容
                                     'ls_come': tr.xpath('./td[8]//text()')[0],  # 数据来源
                                     })
    # all_info.append({'__container_licensing': __container_licensing})
    item['_container_licensing'] = _container_licensing

    # 8.10 微信公众号 -------------------------------------------------------------------------------------------------------------
    wechat = tree.xpath('//*[@id="_container_wechat"]//table[contains(@class,"table")]/tbody/tr')
    _container_wechat = []
    for tr in wechat:
        _container_wechat.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'wechat': tr.xpath('./td[2]//text()')[0],  # 微信公众号
                                  'wechat_id': tr.xpath('./td[3]//text()')[0],  # 微信号
                                  'wechat_code': tr.xpath('./td[4]//img/@data-src')[0],  # 微信二维码
                                  'wechat_introduction': tr.xpath('./td[5]//div/text()')[0].replace('\xa0', ''),  # 简介
                                  })
    # all_info.append({'__container_wechat': __container_wechat})
    item['_container_wechat'] = _container_wechat

    # # 微博 -------------------------------------------------------------------------------------------------------------
    weibo = tree.xpath('//*[@id="_container_weibo"]//table[contains(@class,"table")]/tbody/tr')
    _container_weibo = []
    for tr in weibo:
        _container_weibo.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                 'weibo_name': ''.join(tr.xpath('./td[2]//a/text()')),  # 微博名称
                                 'weibo_url': ''.join(tr.xpath('./td[2]//a/@href')),  # 微博url
                                 'weibo_industry_category': tr.xpath('./td[3]//text()')[0],  # 行业类别
                                 'weibo_introduction': tr.xpath('./td[4]//div/text()')[0],  # 简介
                                 })
    # all_info.append({'__container_weibo': __container_weibo})
    item['_container_weibo'] = _container_weibo

    # # 相关公告  -------------------------------------------------------------------------------------------------------------
    relatedAnnouncement = tree.xpath(
        '//*[@id="_container_relatedAnnouncement"]//table[contains(@class,"table")]/tbody/tr')
    _container_relatedAnnouncement = []
    for tr in relatedAnnouncement:
        _container_relatedAnnouncement.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                               'ra_release_date': ''.join(tr.xpath('./td[2]//a/text()')),  # 发布日期
                                               'ra_publish_type': ''.join(tr.xpath('./td[3]//text()')),  # 发布类型
                                               'ra_content': tr.xpath('./td[4]//text()')[0],  # 公告内容
                                               'ra_href': ''.join(tr.xpath('./td[4]/a/@href')),  # 公告内容连接
                                               })
    # all_info.append({'__container_weibo': __container_weibo})
    item['_container_relatedAnnouncement'] = _container_relatedAnnouncement

    # # 企业研报  -------------------------------------------------------------------------------------------------------------
    companySearchReport = tree.xpath(
        '//*[@id="_container_companySearchReport"]//table[contains(@class,"table")]/tbody/tr')
    _container_companySearchReport = []
    for tr in companySearchReport:
        _container_companySearchReport.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                               'csr_release_date': ''.join(tr.xpath('./td[2]//a/text()')),  # 发布日期
                                               'csr_publish_type': ''.join(tr.xpath('./td[3]//text()')),  # 发布类型
                                               'csr_content': tr.xpath('./td[4]//text()')[0],  # 研报内容
                                               'csr_href': ''.join(tr.xpath('./td[4]/a/@href')),  # 研报内容连接
                                               })
    # all_info.append({'__container_weibo': __container_weibo})
    item['_container_companySearchReport'] = _container_companySearchReport

    # # 进出口信用  -------------------------------------------------------------------------------------------------------------
    importAndExport = tree.xpath('//*[@id="_container_importAndExport"]//table[contains(@class,"table")]/tbody/tr')
    _container_importAndExport = []
    for tr in importAndExport:
        _container_importAndExport.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                           'iae_registration_date': ''.join(tr.xpath('./td[2]//a/text()')),  # 注册日期
                                           'iae_registration_customs': ''.join(tr.xpath('./td[3]//text()')),  # 注册海关
                                           'iae_industry_types': tr.xpath('./td[4]//text()')[0],  # 行业种类
                                           'iae_business_category': ''.join(tr.xpath('./td[5]//text()')),  # 经营类别
                                           'iae_credit_rating': ''.join(tr.xpath('./td[6]//text()')),  # 信用等级
                                           'iae_detail': ''.join(tr.xpath('./td[7]//text()')),  # 详情
                                           })
    # all_info.append({'__container_weibo': __container_weibo})
    item['_container_importAndExport'] = _container_importAndExport

    # # 电信许可  -------------------------------------------------------------------------------------------------------------
    permission = tree.xpath('//*[@id="_container_permission"]//table[contains(@class,"table")]/tbody/tr')
    _container_permission = []
    for tr in permission:
        _container_permission.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                      'p_license': ''.join(tr.xpath('./td[2]//a/text()')),  # 许可证号
                                      'p_business': ''.join(tr.xpath('./td[3]//text()')),  # 业务及其覆盖范围
                                      'p_validity': tr.xpath('./td[4]//text()')[0],  # 是否有效
                                      'p_detail': ''.join(tr.xpath('./td[5]//text()')),  # 详情
                                      })
    # all_info.append({'__container_weibo': __container_weibo})
    item['_container_permission'] = _container_permission

    # # 供应商  -------------------------------------------------------------------------------------------------------------
    supplies = tree.xpath('//*[@id="_container_supplies"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_supplies = []
    for tr in supplies:
        if tr.xpath('./td[1]//text()'):
            _container_supplies.append({'no': tr.xpath('./td[1]//text()')[0],  # 序号
                                        's_supplier': ''.join(tr.xpath('./td[2]//a/text()')),  # 供应商
                                        's_procurement': ''.join(tr.xpath('./td[3]//text()')),  # 采购占比
                                        's_purchase_amount': tr.xpath('./td[4]//text()')[0],  # 采购金额
                                        's_reporting_period': ''.join(tr.xpath('./td[5]//text()')),  # 报告期
                                        's_source': ''.join(tr.xpath('./td[6]//text()')),  # 数据来源
                                        's_correlation': ''.join(tr.xpath('./td[7]//text()')),  # 关联关系
                                        })
    # all_info.append({'__container_weibo': __container_weibo})
    item['_container_supplies'] = _container_supplies

    # # 客户 -------------------------------------------------------------------------------------------------------------
    clients = tree.xpath('//*[@id="_container_clients"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_clients = []
    for tr in clients:
        _container_clients.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                   'c_clients': ''.join(tr.xpath('./td[2]//a/text()')),  # 客户
                                   'c_percentage_ales': tr.xpath('./td[3]//text()')[0],  # 销售占比
                                   'c_sales_amount': tr.xpath('./td[4]//text()')[0],  # 销售金额
                                   'c_report_period': tr.xpath('./td[5]//text()')[0],  # 报告期
                                   'c_data_sources': tr.xpath('./td[6]//text()')[0],  # 数据来源
                                   'c_connection_relation': tr.xpath('./td[7]//text()')[0],  # 关联关系
                                   })
    # all_info.append({'__container_clients': __container_clients})
    item['_container_clients'] = _container_clients

    # # 上榜榜单 -------------------------------------------------------------------------------------------------------------
    rankListCount = tree.xpath('//*[@id="_container_rankListCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_rankListCount = []
    for tr in rankListCount:
        _container_rankListCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                         'rlc_list_name': ''.join(tr.xpath('./td[2]//text()')),  # 榜单名称
                                         'rlc_list_type': tr.xpath('./td[3]//text()')[0],  # 榜单类型
                                         'rlc_source': tr.xpath('./td[4]//text()')[0],  # 来源
                                         'rlc_list_position': tr.xpath('./td[5]//text()')[0],  # 榜内位置
                                         'rlc_name_in_list': tr.xpath('./td[6]//text()')[0],  # 榜内名称
                                         'rlc_release_year': tr.xpath('./td[7]//text()')[0],  # 发布年份
                                         })
    # all_info.append({'__container_rankListCount': __container_rankListCount})
    item['_container_rankListCount'] = _container_rankListCount

    # # 商标信息 -------------------------------------------------------------------------------------------------------------
    tmInfo = tree.xpath('//*[@id="_container_tmInfo"]/div/table[contains(@class,"table")]/tbody/tr')
    _container_tmInfo = []
    for tr in tmInfo:
        print(tr.xpath('//*[@id="_container_tmInfo"]/div/table[contains(@class,"table")]/thead//text()'))
        print(tr.xpath('.//text()'))
        _container_tmInfo.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                  'ti_application_date': ''.join(tr.xpath('./td[2]//text()')),  # 申请日期
                                  'ti_trademark': tr.xpath('./td[3]//img/@data-src')[0],  # 商标
                                  'ti_trademark_name': tr.xpath('./td[4]//text()')[0],  # 商标名称
                                  'ti_registration_num': tr.xpath('./td[5]//text()')[0],  # 注册号
                                  'ti_international_classification': tr.xpath('./td[6]//text()')[0],  # 国际分类
                                  'ti_trademark_status': tr.xpath('./td[7]//text()')[0],  # 商标状态
                                  'ti_href': tr.xpath('./td[8]//a/@href')[0],  # 详情连接
                                  })
    # all_info.append({'__container_tmInfo': __container_tmInfo})
    item['_container_tmInfo'] = _container_tmInfo

    # 九、年报信息================================================================================================================
    # 企业年报-------------------------------------------------------------------------------------------------------------
    nianbao = tree.xpath('//div[@tyc-event-ch="CompangyDetail.nianbao"]//table[contains(@class,"table")]/tbody/tr')
    nianbaos = []
    for tr in nianbao:
        nianbaos.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                         'release_date': tr.xpath('./td[2]//text()')[0],  # 发步日期
                         'year_report': tr.xpath('./td[3]//text()')[0],  # 年报
                         'report_detail': tr.xpath('./td[4]/a/@href')[0],  # 详情网址
                         })
    # all_info.append({'nianbaos': nianbaos})
    item['nianbaos'] = nianbaos

    # 十、历史信息================================================================================================================
    # 历史工商信息-------------------------------------------------------------------------------------------------------------
    pastICV2Count = tree.xpath(
        '//*[@id="_container_pastICV2Count"]//table[contains(@class,"table")]/tbody/tr/td//text()')
    pastICV2Count = '*-*'.join(pastICV2Count).replace('... *-*更多*-*', '').split('*-*')
    _container_pastICV2Count = pastICV2Count
    # all_info.append({'__container_pastICV2Count': __container_pastICV2Count})
    item['_container_pastICV2Count'] = _container_pastICV2Count

    # 历史股东-------------------------------------------------------------------------------------------------------------
    pastHolderCount = tree.xpath('//*[@id="_container_pastHolderCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastHolderCount = []
    for tr in pastHolderCount:
        if tr.xpath('./td[1]/text()'):
            _container_pastHolderCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                               'phc_holder': tr.xpath('./td[2]//a/text()')[0],  # 股东
                                               'phc_holding_ratio': tr.xpath('./td[3]//text()')[0],  # 持股比例
                                               'phc_subscribed_capital_contribution': tr.xpath('./td[4]//text()')[0],
                                               # 认缴出资额
                                               'phc_participation_date': tr.xpath('./td[5]//text()')[0],  # 参股日期
                                               'phc_withdrawal_date': tr.xpath('./td[6]//text()')[0],  # 退股日期
                                               })
    # all_info.append({'__container_pastHolderCount': __container_pastHolderCount})
    item['_container_pastHolderCount'] = _container_pastHolderCount

    # 历史高管-------------------------------------------------------------------------------------------------------------
    pastOfficerCount = tree.xpath('//*[@id="_container_pastOfficerCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastOfficerCount = []
    for tr in pastOfficerCount:
        if tr.xpath('./td[1]/text()'):
            _container_pastOfficerCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                                'poc_name': tr.xpath('./td[2]//a/text()')[0],  # 姓名
                                                'poc_start_date': tr.xpath('./td[3]//text()')[0],  # 任职开始日期
                                                })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastOfficerCount'] = _container_pastOfficerCount

    # 历史对外投资-------------------------------------------------------------------------------------------------------------
    pastInverstCount = tree.xpath('//*[@id="_container_pastInverstCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastInverstCount = []
    for tr in pastInverstCount:
        if tr.xpath('./td[1]/text()'):
            _container_pastInverstCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                                'pic_invested_company_name': tr.xpath('./td[2]//a/text()')[0],  # 被投资企业名称
                                                'pic_legal_representative': tr.xpath('./td[3]//a/text()')[0],  # 法定代表人
                                                'pic_set_date': tr.xpath('./td[4]//text()')[0],  # 成立日期
                                                'pic_investment_amount': tr.xpath('./td[5]//text()')[0],  # 投资数额
                                                'pic_investment_ratio': tr.xpath('./td[6]//text()')[0],  # 投资比例
                                                'pic_operating_status': tr.xpath('./td[7]//text()')[0],  # 经营状态
                                                'pic_related_products': tr.xpath('./td[8]//text()')[0],  # 关联产品
                                                'pic_related_institutions': tr.xpath('./td[9]//text()')[0],  # 关联机构
                                                })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastInverstCount'] = _container_pastInverstCount

    # 历史开庭公告-------------------------------------------------------------------------------------------------------------
    pastAnnouncementCount = tree.xpath(
        '//*[@id="_container_pastAnnouncementCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastAnnouncementCount = []
    for tr in pastAnnouncementCount:
        _container_pastAnnouncementCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                                 'pac_court_date': tr.xpath('./td[2]//text()')[0],  # 开庭日期
                                                 'pac_case_num': tr.xpath('./td[3]//text()')[0],  # 案号
                                                 'pac_case_cause': tr.xpath('./td[4]//text()')[0],  # 案由
                                                 'pac_case_status': ''.join(tr.xpath('./td[5]//text()')),  # 案件身份
                                                 'pac_trial_court': tr.xpath('./td[6]//text()')[0],  # 审理法院
                                                 'pac_detail': tr.xpath('./td[7]//text()')[0],  # 详情
                                                 })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastAnnouncementCount'] = _container_pastAnnouncementCount

    # 历史法律诉讼-------------------------------------------------------------------------------------------------------------
    pastLawsuitCount = tree.xpath('//*[@id="_container_pastLawsuitCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastLawsuitCount = []
    for tr in pastLawsuitCount:
        _container_pastLawsuitCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                            'plc_referee_date': tr.xpath('./td[2]//text()')[0],  # 裁判日期
                                            'plc_case_name': tr.xpath('./td[3]//text()')[0],  # 案件名称
                                            'plc_case_id': tr.xpath('./td[4]//text()')[0],  # 案号
                                            'plc_case_cause': ''.join(tr.xpath('./td[5]//text()')),  # 案由
                                            'plc_case_status': ''.join(tr.xpath('./td[6]//text()')),  # 案件身份
                                            'plc_referee_result': ''.join(tr.xpath('./td[7]//text()')).replace(
                                                '...', '').replace('更多', ''),  # 裁判结果
                                            'plc_trial_court': tr.xpath('./td[8]//text()')[0],  # 审理法院
                                            'plc_release_date': tr.xpath('./td[9]//text()')[0],  # 发布日期
                                            'plc_href': tr.xpath('./td[10]/a/@href')[0],  # 详情连接
                                            })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastLawsuitCount'] = _container_pastLawsuitCount

    # 历史法院公告-------------------------------------------------------------------------------------------------------------
    pastCourtCount = tree.xpath('//*[@id="_container_pastCourtCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastCourtCount = []
    for tr in pastCourtCount:
        _container_pastCourtCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'pcc_published_date': tr.xpath('./td[2]//text()')[0],  # 刊登日期
                                          'pcc_case_id': tr.xpath('./td[3]//text()')[0],  # 案号
                                          'pcc_case_cause': tr.xpath('./td[4]//text()')[0],  # 案由
                                          'pcc_case_status': ''.join(tr.xpath('./td[5]//text()')),  # 案件身份
                                          'pcc_announcement_type': ''.join(tr.xpath('./td[6]//text()')),  # 公告类型
                                          'pcc_court': ''.join(tr.xpath('./td[7]//text()')),  # 法院
                                          'pcc_detail': ''.join(tr.xpath('./td[8]//text()')),  # 详情
                                          })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastCourtCount'] = _container_pastCourtCount

    # 历史行政处罚-------------------------------------------------------------------------------------------------------------
    pastPunishmentICV2 = tree.xpath(
        '//*[@id="_container_pastPunishmentICV2"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastPunishmentICV2 = []
    for tr in pastPunishmentICV2:
        _container_pastPunishmentICV2.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                              'ppicv_penalty_date': tr.xpath('./td[2]//text()')[0],  # 处罚日期
                                              'ppicv_decision_document_num': tr.xpath('./td[3]//text()')[0],  # 决定文书号
                                              'ppicv_penalties': ''.join(tr.xpath('./td[4]//text()')).replace(
                                                  '...', '').replace('更多', ''),  # 处罚事由/违法行为类型
                                              'ppicv_penalty_result': ''.join(tr.xpath('./td[5]//text()')).replace(
                                                  '...', '').replace('更多', ''),  # 处罚结果/内容
                                              'ppicv_punishment_unit': ''.join(tr.xpath('./td[6]//text()')),  # 处罚单位
                                              'ppicv_data_sources': ''.join(tr.xpath('./td[7]//text()')),  # 数据来源
                                              })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastPunishmentICV2'] = _container_pastPunishmentICV2

    # 历史股权出质-------------------------------------------------------------------------------------------------------------
    pastEquityCount = tree.xpath('//*[@id="_container_pastEquityCount"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastEquityCount = []
    for tr in pastEquityCount:
        _container_pastEquityCount.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                           'pec_registration_date': tr.xpath('./td[2]//text()')[0],  # 股权出质设立登记日期
                                           'pec_registration_id': tr.xpath('./td[3]//text()')[0],  # 登记编号
                                           'pec_pledger': ''.join(tr.xpath('./td[4]//text()')),  # 出质人
                                           'pec_pledged_equity_target': ''.join(tr.xpath('./td[5]//text()')),
                                           # 出质股权标的企业
                                           'pec_pledgee': ''.join(tr.xpath('./td[6]//text()')),  # 质权人
                                           'pec_pledged_equity_amount': ''.join(tr.xpath('./td[7]//text()')),  # 出质股权数额
                                           'pec_status': ''.join(tr.xpath('./td[7]//text()')),  # 状态
                                           'pec_detail': ''.join(tr.xpath('./td[7]//text()')),  # 详情
                                           })
    # all_info.append({'__container_pastOfficerCount': __container_pastOfficerCount})
    item['_container_pastEquityCount'] = _container_pastEquityCount

    # 历史行政许可-------------------------------------------------------------------------------------------------------------
    pastLicenseCreditICV2 = tree.xpath(
        '//*[@id="_container_pastLicenseCreditICV2"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastLicenseCreditICV2 = []
    for tr in pastLicenseCreditICV2:
        _container_pastLicenseCreditICV2.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                                 'plc_decision_date': tr.xpath('./td[2]//text()')[0],  # 决定日期/有效期自
                                                 'plc_deadline': tr.xpath('./td[3]//text()')[0],  # 截止日期/有效期至
                                                 'plc_instrument_num': tr.xpath('./td[4]//text()')[0],  # 许可文件编号/文书号
                                                 'plc_license_name': tr.xpath('./td[5]//text()')[0],  # 许可文件名称
                                                 'plc_license_organ': tr.xpath('./td[6]//text()')[0],  # 决定/许可机关
                                                 'plc_license_centent': ''.join(
                                                     tr.xpath('./td[7]//div/text()')).replace(
                                                     '...', '').replace('更多', ''),  # 许可内容
                                                 'plc_data_sources': tr.xpath('./td[8]//text()')[0],  # 数据来源
                                                 })
    # all_info.append({'__container_pastLicenseCreditICV2': __container_pastLicenseCreditICV2})
    item['_container_pastLicenseCreditICV2'] = _container_pastLicenseCreditICV2

    # 历史商标信息-------------------------------------------------------------------------------------------------------------
    pastTmInfo = tree.xpath('//*[@id="_container_pastTmInfo"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastTmInfo = []
    for tr in pastTmInfo:
        _container_pastTmInfo.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                      'pti_application_date': tr.xpath('./td[2]//text()')[0],  # 申请日期
                                      'pti_trademark': tr.xpath('./td[3]//img/@data-src')[0],  # 商标
                                      'pti_trademark_name': tr.xpath('./td[4]//text()')[0],  # 商标名称
                                      'pti_registration_num': tr.xpath('./td[5]//text()')[0],  # 注册号
                                      'pti_international_classification': tr.xpath('./td[6]//text()')[0],  # 国际分类
                                      'pti_trademark_status': ''.join(tr.xpath('./td[7]//div/text()')),  # 商标状态
                                      'pti_href': tr.xpath('./td[8]/a/@href')[0],  # 详情连接
                                      })
    # all_info.append({'__container_pastLicenseCreditICV2': __container_pastLicenseCreditICV2})
    item['_container_pastTmInfo'] = _container_pastTmInfo

    # 历史网站备案-------------------------------------------------------------------------------------------------------------
    pastIcpList = tree.xpath('//*[@id="_container_pastIcpList"]//table[contains(@class,"table")]/tbody/tr')
    _container_pastIcpList = []
    for tr in pastIcpList:
        _container_pastIcpList.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                       'pil_review_date': tr.xpath('./td[2]//text()')[0],  # 审核日期
                                       'pil_site_name': tr.xpath('./td[3]//text()')[0],  # 网站名称
                                       'pil_home_page': ''.join(tr.xpath('./td[4]//text()')),  # 网站首页
                                       'pil_domain_name': tr.xpath('./td[5]//text()')[0],  # 域名
                                       'pil_permit_number': tr.xpath('./td[6]//text()')[0],  # 网站备案/许可证号
                                       'pil_public_security_record': ''.join(tr.xpath('./td[7]//div/text()')),  # 公安备案
                                       })
    # all_info.append({'__container_pastLicenseCreditICV2': __container_pastLicenseCreditICV2})
    item['_container_pastIcpList'] = _container_pastIcpList

    # 最终受益人-------------------------------------------------------------------------------------------------------------
    humanholding = tree.xpath('//*[@id="_container_humanholding"]//table[contains(@class,"table")]/tbody/tr')
    _container_humanholding = []
    for tr in humanholding:
        _container_humanholding.append({'no': ''.join(tr.xpath('./td[1]/span/text()')),  # 序号
                                        'hh_name': ''.join(tr.xpath('./td[2]//a/text()')),  # 最终受益人名称
                                        'hh_proportion': ''.join(tr.xpath('./td[3]/span/text()')),  # 持股比例
                                        'hh_benefit': ''.join(tr.xpath('./td[4]//text()')).replace('\xa0', ''),  # 股权链、
                                        })
    # all_info.append({'__container_holder': __container_holder})
    item['_container_humanholding'] = _container_humanholding

    # 实际控制权-------------------------------------------------------------------------------------------------------------
    holding_company = tree.xpath('//*[@id="_container_companyholding"]//table[contains(@class,"table")]/tbody/tr')
    _container_companyholding = []
    for tr in holding_company:
        _container_companyholding.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'c_name': tr.xpath('./td[2]//a/text()')[0],  # 控股企业名称
                                          'c_ratio': tr.xpath('./td[3]/span/text()')[0],  # 投资比例
                                          'c_chain': ''.join(tr.xpath('./td[4]//text()')).replace('\xa0', ''),  # 投资链
                                          })
    # all_info.append({'__container_companyholding': __container_companyholding})
    item['_container_companyholding'] = _container_companyholding
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    # all_info = [dic for dic in all_info if dic.values()]  # 保留空值
    # all_info = [dic for dic in all_info if list(dic.values())[0]]
    # for k, v in item.items():
    #     print(f'{k} ==> {v}')
    # print('*' * 200)
    return item


def get_holding(res):
    tree = etree.HTML(res.text)
    item = {}
    # 最终受益人-------------------------------------------------------------------------------------------------------------
    humanholding = tree.xpath('//*[@id="_container_humanholding"]//table[contains(@class,"table")]/tbody/tr')
    _container_humanholding = []
    for tr in humanholding:
        _container_humanholding.append({'no': ''.join(tr.xpath('./td[1]/span/text()')),  # 序号
                                        'hh_name': ''.join(tr.xpath('./td[2]//a/text()')),  # 最终受益人名称
                                        'hh_proportion': ''.join(tr.xpath('./td[3]/span/text()')),  # 持股比例
                                        'hh_benefit': ''.join(tr.xpath('./td[4]//text()')).replace('\xa0', ''),  # 股权链、
                                        })
    # all_info.append({'__container_holder': __container_holder})
    item['_container_humanholding'] = _container_humanholding

    # 实际控制权-------------------------------------------------------------------------------------------------------------
    holding_company = tree.xpath('//*[@id="_container_companyholding"]//table[contains(@class,"table")]/tbody/tr')
    _container_companyholding = []
    for tr in holding_company:
        _container_companyholding.append({'no': tr.xpath('./td[1]/text()')[0],  # 序号
                                          'c_name': tr.xpath('./td[2]//a/text()')[0],  # 控股企业名称
                                          'c_ratio': tr.xpath('./td[3]/span/text()')[0],  # 投资比例
                                          'c_chain': ''.join(tr.xpath('./td[4]//text()')).replace('\xa0', ''),  # 投资链
                                          })
    # all_info.append({'__container_companyholding': __container_companyholding})
    item['_container_companyholding'] = _container_companyholding

    # for k, v in item.items():
    #     print(f'{k} ==> {v}')
    # print('*' * 200)
    return item


def xpath_get_detail_url(res):
    tree = etree.HTML(res.text)
    divs = tree.xpath('//*[@id="web-content"]//div[contains(@class,"result-list")]/div')
    item_list = []
    for div in divs:
        item = {}
        item['detail_url'] = ''.join(div.xpath('.//a[contains(@class,"name")]/@href'))
        item['company_name'] = ''.join(div.xpath('.//a[contains(@class,"name")]/text()'))
        item['status'] = ''.join(div.xpath('.//div[contains(@class,"tag")]/text()')).replace('小微企业', '')
        item['phone'] = ''.join(div.xpath('.//span[contains(text(),"电话")]/following-sibling::span[1]/text()'))
        item['legal_represent'] = ''.join(div.xpath('.//a[contains(@class,"legalPersonName")]/text()'))
        item['registered_capital'] = ''.join(div.xpath('.//div[contains(text(),"注册资本")]/span/text()'))
        item['set_time'] = ''.join(div.xpath('.//div[contains(text(),"成立日期")]/span/text()'))
        item['add'] = ''.join(div.xpath('.//div[contains(text(),"地址")]/text()')).replace('地址：', '')
        if item['detail_url']:
            item_list.append(item)

    return item_list
